package pers.lan.linkedlist;

/**
 * @author <p><a href="mailto:1728209643@qq.com">XiaoSan</a>
 * @date 2019/9/7 7:34 PM
 */
public class LC_876 {

    public static void main(String[] args) {
        System.out.println(
                new LC_876().middleNode(ListNode.build(new int[]{1, 2, 3, 4, 5, 6}))
        );
    }

    public ListNode middleNode(ListNode head) {
        ListNode p = head, q = head;
        int i = 0;
        while (p != null) {
            p = p.next;
            if (i % 2 == 1) {
                q = q.next;
            }
            i++;
        }
        return q;
    }
}
